﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using zz.RestMVC.MVC;
//using System.Web.Mvc;
using System.Web;
using System.IO;
using Newtonsoft.Json;

namespace XM.Comm
{
    public class FormatJsonResult
    {
        private bool isSuccess = true;
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool IsSuccess
        {
            get;
            set;
        }
        /// <summary>
        /// 错误或者成功信息
        /// </summary>
        public string Message
        {
            get;
            set;
        }
        /// <summary>
        /// 成功时可能返回的数据
        /// </summary>
        public object Data
        {
            get;
            set;
        }
        /// <summary>
        /// 正常序列化方式（True为不进行UI友好的序列化）
        /// </summary>
        public bool NotEasyUIFriendlySerialize
        {
            get;
            set;
        }
        //public override void ExecuteResult(ControllerContext context) 
        //{
            
        //}


        //public override void HandlerOutput(System.Security.Response response)
        //{
        //    //if (context == null)
        //    //{
        //    //    throw new ArgumentNullException("context");
        //    //}
        //    //HttpResponseBase response =response. context.HttpContext.Response;
        //    response.ContentType = "application/json";
        //    StringWriter sw = new StringWriter();
        //    JsonSerializer serializer = JsonSerializer.Create(
        //        new JsonSerializerSettings
        //        {
        //            ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
        //            NullValueHandling = NullValueHandling.Ignore
        //        });
        //    using (JsonWriter jsonWriter = new JsonTextWriter(sw))
        //    {
        //        jsonWriter.Formatting = Formatting.Indented;
        //        if (!NotEasyUIFriendlySerialize)
        //        {
        //            serializer.Serialize(jsonWriter, this);
        //        }
        //        else
        //        {
        //            serializer.Serialize(jsonWriter, Data);
        //        }
        //    }
        //    response.Write(sw.ToString());
        //}
    }
}
